﻿using System.Collections;
using System.Collections.Generic;
using System.Data.SqlClient;
using Framework.DataAccess;
using Project.Domain.Entities;

namespace Project.DAL.Repository
{
    public interface ISoccerTeamRepository :IRepository<SoccerTeam>
    {
         IEnumerable<SoccerTeam> GetHomeTeamByLeagueId(int leagueId,int status,int inPlay);
         IEnumerable<SoccerTeam> GetAwayTeamByLeagueId(int leagueId, int status, int inPlay);
    }

    public class SoccerTeamRepository :RepositoryBase<SoccerTeam>, ISoccerTeamRepository
    {
        public SoccerTeamRepository(IDatabaseFactory databaseFactory)
            : base(databaseFactory)
        {
        }

        #region ISoccerTeamRepository Members

        public IEnumerable<SoccerTeam> GetHomeTeamByLeagueId(int leagueId, int status, int inPlay)
        {
            return DomainContext.Database.SqlQuery<SoccerTeam>("GetHomeTeamByLeagueId @LeagueId,@Status,@InPlay",
                 new SqlParameter("@LeagueId", leagueId),
                 new SqlParameter("@Status", status),
                 new SqlParameter("@inPlay", inPlay));
        }

        #endregion

        #region ISoccerTeamRepository Members


        public IEnumerable<SoccerTeam> GetAwayTeamByLeagueId(int leagueId, int status, int inPlay)
        {
            return DomainContext.Database.SqlQuery<SoccerTeam>("GetAwayTeamByLeagueId @LeagueId,@Status,@InPlay",
                 new SqlParameter("@LeagueId", leagueId),
                  new SqlParameter("@Status", status),
                  new SqlParameter("@inPlay", inPlay));            
        }

        #endregion
    }
}